/*
* 数据分析模块
* */
// import api from '../../api/index'

const moduleItem = {
  namespaced: true,
  state: {
    cityCode: '420100', // 查询选择的城市编码
    cityCodeList: '', // 城市列表数据
    topTotal: '', // 顶部汇总
    table: [], // 表头数据
    tableData: [], // 表格展示数据
    tableDataTotal: [], // 表格所有数据
    page: {// 分页数据
      pageNum: 1,
      pageSize: 10,
      total: 0
    },
    newTable: [], // 用户分析新用户表头
    oldTable: [], // 用户分析老用户表头
    payWeekTable: [], // 支付分析上周表头
    payMonthTable: [], // 用户分析上月表头
    payCustomTable: [], // 支付分析自定义时间段表头
    payCompareTable: [] // 用户分析对比表头
  },
  mutations: {
    cityCode (state, data) {
      state.cityCode = data
    },
    cityCodeList (state, data) {
      state.cityCodeList = data
    },
    topTotal (state, data) {
      state.topTotal = data
    },
    table (state, data) {
      state.table = data
    },
    newTable (state, data) {
      state.newTable = data
    },
    oldTable (state, data) {
      state.oldTable = data
    },
    payWeekTable (state, data) {
      state.payWeekTable = data
    },
    payMonthTable (state, data) {
      state.payMonthTable = data
    },
    payCustomTable (state, data) {
      state.payCustomTable = data
    },
    payCompareTable (state, data) {
      state.payCompareTable = data
    },
    tableData (state, data) {
      state.tableData = data
    },
    tableDataTotal (state, data) {
      state.tableDataTotal = data
    },
    page (state, data) {
      state.page = data
    }
  },
  actions: {
    setTable ({ commit }, array) { // 初始化表头
      commit('table', array)
    },
    setNewTable ({ commit }, array) { // 初始化表头
      commit('newTable', array)
    },
    setOldTable ({ commit }, array) { // 初始化表头
      commit('oldTable', array)
    },
    setPayWeekTable ({ commit }, array) { // 初始化表头
      commit('payWeekTable', array)
    },
    setPayMonthTable ({ commit }, array) { // 初始化表头
      commit('payMonthTable', array)
    },
    setPayCustomTable ({ commit }, array) { // 初始化表头
      commit('payCustomTable', array)
    },
    setPayCompareTable ({ commit }, array) { // 初始化表头
      commit('payCompareTable', array)
    },
    setTableData ({ commit }, obj) { // 初始化表格展示数据
      commit('tableData', obj)
    },
    setTableDataTotal ({ commit }, obj) { // 初始化表格所有数据
      commit('tableDataTotal', obj)
    },
    setPage ({ commit }, obj) { // 初始化表格分页数据
      commit('page', obj)
    },
    getCityCodeList ({ commit }, obj) { // 城市列表
      let cityCodeArr = JSON.parse(sessionStorage.getItem('indexRouter'))
      commit('cityCodeList', cityCodeArr.slice(1))
    },
    setCityCode ({ commit }, data) {
      commit('cityCode', data)
    }
  }
}

export default moduleItem
